<!--
 * @Author: Bun 
 * @Date: 2020-03-06 18:57:37 
 * @Last Modified by:   Bun 
 * @Last Modified time: 2020-03-06 18:57:37 
  -->

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script type="text/javascript">
        window.onload = function(){
/*          document.getElementById('div1').style.color= 'red';
            document.getElementById('div1').style.fontSize = '30px'; */
            /* 变量简化代码 */
            var oDiv = document.getElementById('div1');
            oDiv.style.color = 'red';
            oDiv.style.fontSize = '30px';

        }
    </script>
    <title>Document</title>
</head>
<body>
    <div id="div1">这是一个div元素</div>
<!--     <script type="text/javascript">
        document.getElementById('div1').style.color = 'red';
    </script> -->
</body>
</html>